package cn.legend.travel.guide.util;

import cn.legend.travel.guide.pojo.entity.User;
import cn.legend.travel.guide.pojo.po.GuidePO;
import cn.legend.travel.guide.pojo.vo.GuideVO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;

public class GuidePOListToGuideVOConvertor {
    public static List<GuideVO> convert(List<GuidePO> guideList){

        List<GuideVO> list = new ArrayList<>();
        if(guideList.isEmpty()){
            return null;
        }
        for (GuidePO guidePO : guideList) {
            GuideVO guideVO = new GuideVO();
            BeanUtils.copyProperties(guidePO,guideVO);
            switch (guidePO.getType()){
                case 0:
                    guideVO.setType("美食");
                    break;
                case 1:
                    guideVO.setType("景点");
                    break;
                case 2:
                    guideVO.setType("城市");
                    break;
                case 3:
                    guideVO.setType("酒店");
                    break;
                default:
                    guideVO.setType("其他");
                    break;
            }
           // String[] user = {guidePO.getAuthorId().toString(),guidePO.getAvatar(),guidePO.getUsername()};
            User user = new User();
            user.setId(guidePO.getAuthorId());
            user.setNickName(guidePO.getUsername());
            user.setImgUrl(guidePO.getAvatar());
            guideVO.setUser(user);
            list.add(guideVO);
        }

        return list;
    }
}
